package com.knowif.service;

import com.knowif.dao.ItemMapper;
import com.knowif.pojo.Item;
import com.knowif.pojo.ItemExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author xingyao
 * @Description: 栏目管理dao服务层
 */
@Service
public class Item_service {

    @Autowired
    private ItemMapper itemMapper;

    /**
     * 类目查询
     * @param itemExample
     * @return
     */
    public List<Item> selectItem(ItemExample itemExample){
        return itemMapper.selectByExample(itemExample);
    }

    /**
     * 插入item
     * @param item
     * @return
     */
    public int saveItem(Item item){
        return itemMapper.insert(item);
    }

    /**
     * 更新不为空的item属性
     * @param item
     * @return
     */
    public int updateItemNotNull(Item item){
        return itemMapper.updateByPrimaryKeySelective(item);
    }

    /**
     * 更新所有item属性
     * @param item
     * @return
     */
    public int updateItem(Item item){
        return itemMapper.updateByPrimaryKey(item);
    }

    /**
     * 删除item
     * @param itemId
     */
    public int deleteItem(int itemId){
        return itemMapper.deleteByPrimaryKey(itemId);
    }

}
